package com.deep.test

import org.apache.spark.mllib.random.RandomRDDs._
import org.apache.spark.{SparkConf, SparkContext}
import org.apache.spark.mllib.stat.KernelDensity
import org.apache.spark.rdd.RDD

/**
 * @author sw
 * @create 2023-05-29 15:57
 */
object Test13 {
  def main(args: Array[String]): Unit = {
    val conf = new SparkConf().setMaster("local").setAppName("ALS")
    val sc = new SparkContext(conf)
    sc.setLogLevel("WARN")

    val test = sc.textFile("data/iris.data").map(_.split(",")).map(p => p(0).toDouble)
    val kd = new KernelDensity().setSample(test).setBandwidth(3.0)
    val densities = kd.estimate(Array(-1.0, 2.0, 5.0, 5.8))
    densities.foreach {
      println
    }
  }
}
